<!-- 上级菜单选择下拉框 -->
<template>
  <el-tree-select
    clearable
    :data="data"
    check-strictly
    default-expand-all
    node-key="id"
    :props="{ label: 'title' }"
    :placeholder="placeholder"
    :model-value="modelValue || undefined"
    class="ele-fluid"
    filterable
    @update:model-value="updateValue"
  />
</template>

<script setup>
defineProps({
  /** 选中的菜单 */
  modelValue: Number,
  /** 提示信息 */
  placeholder: {
    type: String,
    default: '请选择上级菜单',
  },
  data: {
    type: Array,
    default: () => [],
  },
})

const emit = defineEmits(['update:modelValue'])

/** 更新选中数据 */
function updateValue(value) {
  emit('update:modelValue', value || 0)
}
</script>
